package com.sibu.yx.promotion.common.enums;

import com.doubo.common.util.EnumUtil;

import lombok.Getter;

/**
 * 数据库类型枚举
 */
public enum DataSourceTypeEnum {
    MASTER_DB("master", "默认主库"),
    SYS_DB("sys", "系统分析库"),

    ;

    @Getter
    private String code;
    @Getter
    private String desc;

    DataSourceTypeEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public String getDesc(String code) {
        for (DataSourceTypeEnum enumObj : DataSourceTypeEnum.values()) {
            if (enumObj.getCode() == code) {
                return enumObj.desc;
            }
        }
        return code + "";
    }

    public static DataSourceTypeEnum resolve(int value) {
        return EnumUtil.fromEnumValue(DataSourceTypeEnum.class, "code", value);
    }
}
